package com.eportal.api;

import java.util.Date;

import org.apache.log4j.Logger;
import org.junit.Test;

import com.eportal.domain.TShelves;
import com.eportal.domain.TStrategy;
import com.eportal.util.Config;

public class MdOpenApiTest {

	Logger log = Logger.getLogger(MdOpenApiTest.class);
//	@Test
//	public void testAddAgent() {
//		try {
//			MdOpenAddAgentJson json = MdOpenApi.addAgent("1159547949@qq.com", "老司机", "15558192592", "测试合作方1", "海创园6幢", "");
//			System.out.println(json.isSuccess());
//			System.out.println(json.getCode());
//			System.out.println(json.getMsg());
//			if(json.isSuccess()){
//				System.out.println(json.getData().getAgtcode());
//				System.out.println(json.getData().getAgtkey());
//				System.out.println(json.getData().getAppkey());
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
	
//	@Test
//	public void testAddCommunity() {
//		try {
//			MdOpenAddCommunityJson json =  MdOpenApi.addCommunity("测试小区1", "浙江省杭州市西湖区", "老司机", "15558192592", "", "", "", "");
//			System.out.println(json.isSuccess());
//			System.out.println(json.getCode());
//			System.out.println(json.getMsg());
//			if(json.isSuccess()){
//				System.out.println(json.getData().getDepartid());
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
	
//	@Test
//	public void testInstallLock() {
//		try {
//			MdOpenBaseJson json = MdOpenApi.installLock("BLZXC160400001", "10002000006", "MD30测试LOCK", null, null, null, null, null);
//			
//			System.out.println(json.isSuccess());
//			System.out.println(json.getCode());
//			System.out.println(json.getMsg());
//
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
	
//	@Test
//	public void testQryKey() {
//		try {
//			MdOpenQryKeysJson json = MdOpenApi.qeyKeys(Config.MD_OPEN_AGT_NUM,Config.MD_OPEN_APP_KEY,"BLZXC160400001", "15558192591", "2016052");
//			System.out.println(json.isSuccess());
//			System.out.println(json.getCode());
//			
//			if(json.isSuccess()){
//				MdOpenQryKeysJson.Key key = (MdOpenQryKeysJson.Key)json.getMsg();
//				System.out.println(key.getLock_id());
//			}else{
//				System.out.println(json.getMsg());
//			}
//
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
//	@Test
	public void testTshekvesAdd() {
		try {
			TShelves tShelves = new TShelves();
			tShelves.setName("测试资源清明节2");
			tShelves.setType("I");
			tShelves.setVisiAble(0);
			tShelves.setIsOnLine(1);
			tShelves.setContent("/upload/certificate/1468821357271.jpg");
			tShelves.setcUrl("www.baidu.com");
			tShelves.setOpenSid("73");
			MdOpenAddTShelvesJson json = MdOpenApi.addTShelves(tShelves,Config.MD_OPEN_AGT_NUM,Config.MD_OPEN_APP_KEY);
			System.out.println(json.isSuccess());
			System.out.println(json.getCode());
			System.out.println(json.getData().getSid());
		} catch (Exception e) {
			e.printStackTrace();
			log.error(this, e);
		}
	}
	@Test
	public void testTStrategyAdd() {
		try {
			TStrategy tStrategy = new TStrategy();
			tStrategy.setShid(11l);
			tStrategy.setPriority(1);
			tStrategy.setCommunityId("12,13,14");
			tStrategy.setTimeFrom(new Date());
			tStrategy.setTimeTo(new Date());
			tStrategy.setShowTime("07:00");
			tStrategy.setExpiredTime("08:00");
			tStrategy.setEnabledflag(1);
			tStrategy.setOpenSid("109");
//			MdOpenAddTShelvesJson json = MdOpenApi.addTStrategy(tStrategy,Config.MD_OPEN_AGT_NUM,Config.MD_OPEN_APP_KEY);
//			MdOpenBaseJson json2 = MdOpenApi.editTStrategy(tStrategy,Config.MD_OPEN_AGT_NUM,Config.MD_OPEN_APP_KEY);
//			System.out.println(json.isSuccess());
//			System.out.println(json.getCode());
//			System.out.println(json.getData().getSid());
		} catch (Exception e) {
			e.printStackTrace();
			log.error(this, e);
		}
	}
}

